package LEETCODE2023;

public class Solution_1800 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 2, 3, 5, 3, 6, 9, 10};
        System.out.println(maxAscendingSum(nums));
    }

    public static int maxAscendingSum(int[] nums) {
//            if(nums.length==0){
//                    return 0;
//            }
        int max = 0;
        int temp = nums[0];
        if (nums.length == 1) {
            return temp;
        }
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[i - 1]) {
                temp += nums[i];
            } else {
                max = Math.max(max, temp);
                temp = nums[i];
            }
            if (i == nums.length - 1) {
                max = Math.max(max, temp);
            }
        }
        return max;
    }
    public int guanfangmaxAscendingSum(int[] nums) {
        int res = 0;
        int l = 0;
        while (l < nums.length) {
            int cursum = nums[l++];
            while (l < nums.length && nums[l] > nums[l - 1]) {
                cursum += nums[l++];
            }
            res = Math.max(res, cursum);
        }
        return res;
    }
}
